#ifndef SERIALIZABLE_H
#define SERIALIZABLE_H



#include "d20Model_global.h"



#include <QSharedData>
#include <QSharedDataPointer>
#include <QFileInfo>



class D20_MODELSHARED_EXPORT Serializable
{
    class Data : public QSharedData
    {
    public:
        Data() {}
        Data(const Data& other) : QSharedData(other), file_info(other.file_info) {}

        QFileInfo file_info;
        QString last_error;

        bool dirty;
    };


public:

    Serializable();
    Serializable(const Serializable& other);

    void setFilePath(const QString& file_path);
    QString filePath() const;

    QFileInfo fileInfo() const;

    QString error() const;

    void setDirty(const bool& dirty);
    bool isDirty() const;

    virtual bool save();
    virtual bool saveAs(const QString& file_path);
    virtual bool open(const QString& file_path);

    virtual void setSerializedData(const QString& data) = 0;
    virtual QString serializedData() const = 0;

private:

    QSharedDataPointer<Data> data;

};



#endif // SERIALIZABLE_H
